import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        Scanner p = new Scanner(System.in);
        boolean r = true;
        String rety ;
        int player;
        System.out.println("感谢游玩猜数字");
        while (r) {
            int i=1;
            int answer = (int) (Math.random() * 100 + 1);
            for (; i <= 7; i++) {
                System.out.println("您还剩" + (8 - i) + "次机会");
                player = p.nextInt();
                if (answer == player) {
                    System.out.println("答对啦");
                    break;
                } else if (answer > player) {
                    System.out.println("小啦");
                } else {
                    System.out.println("大啦");
                }
                if (i == 7) {
                    System.out.println("没有机会啦！");
                }
            }
            System.out.println("还要再玩一次吗y/n");
            rety = p.next();
            if (rety.equals("n")){
                r=false;
            }
        }
    }
}
